/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JBMICalcFrame.java
 *
 * Created on 20.03.2009, 19:41:56
 */

package jbmicalc;

import java.util.ResourceBundle;
import javax.swing.SpinnerNumberModel;

/**
 *
 * @author uli
 */
public class JBMICalcFrame extends javax.swing.JFrame {

    /** Creates new form JBMICalcFrame */
    public JBMICalcFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        massLabel = new javax.swing.JLabel();
        massSpinner = new jbmicalc.JNumberSpinner();
        massUnitLabel = new javax.swing.JLabel();
        sizeLabel = new javax.swing.JLabel();
        sizeSpinner = new jbmicalc.JNumberSpinner();
        sizeUnitlabel = new javax.swing.JLabel();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle( i18n.getString("JBMICalcFrame.title")); // NOI18N

        massLabel.setText( i18n.getString("JBMICalcFrame.massLabel.text")); // NOI18N

        massSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(70), Integer.valueOf(0), null, Integer.valueOf(1)));

        massUnitLabel.setText( i18n.getString("JBMICalcFrame.massUnitLabel.text")); // NOI18N

        sizeLabel.setText( i18n.getString("JBMICalcFrame.sizeLabel.text")); // NOI18N

        sizeSpinner.setModel(new SpinnerNumberModel(1.75, 0.1, 5.0, 0.1));

        sizeUnitlabel.setText( i18n.getString("JBMICalcFrame.sizeUnitlabel.text")); // NOI18N

        okButton.setText( i18n.getString("JBMICalcFrame.okButton.text")); // NOI18N
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(okButton, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(massLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(massSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(sizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(sizeSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(massUnitLabel)
                            .addComponent(sizeUnitlabel))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(massLabel)
                    .addComponent(massSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(massUnitLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sizeLabel)
                    .addComponent(sizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sizeUnitlabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(okButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_okButtonActionPerformed
    {//GEN-HEADEREND:event_okButtonActionPerformed
        double mass = massSpinner.getDoubleValue();
        double size = sizeSpinner.getDoubleValue();
        BMIAlgo.calcBMI(mass, size);
    }//GEN-LAST:event_okButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JBMICalcFrame().setVisible(true);
            }
        });
    }

    private ResourceBundle i18n = ResourceBundle.getBundle("jbmicalc/Bundle");
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel massLabel;
    private jbmicalc.JNumberSpinner massSpinner;
    private javax.swing.JLabel massUnitLabel;
    private javax.swing.JButton okButton;
    private javax.swing.JLabel sizeLabel;
    private jbmicalc.JNumberSpinner sizeSpinner;
    private javax.swing.JLabel sizeUnitlabel;
    // End of variables declaration//GEN-END:variables

}
